package com.my.content.ui_homework.fragment.StarSale;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.my.content.ui_homework.Constant;
import com.my.content.ui_homework.R;

/**
 * A simple {@link Fragment} subclass.
 */
public class StarSaleFragment extends Fragment {

    private String[] url = {Constant.STAR_ONE_URL, Constant.STAR_TWO_URL, Constant.STAR_THREE_URL, Constant.STAR_FOUR_URL
            , Constant.STAR_FIVE_URL, Constant.STAR_SIX_URL, Constant.STAR_SEVEN_URL, Constant.STAR_EIGHT_URL, Constant.STAR_NINE_URL};
    private TabLayout mTb;
    private RelativeLayout mRl;
    private Bundle bundle;

    public StarSaleFragment() {
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_star_sale, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mTb = (TabLayout) view.findViewById(R.id.star_tab);
        mRl = (RelativeLayout) view.findViewById(R.id.star_rl);
//        bundle = new Bundle();
        String[] title = getResources().getStringArray(R.array.star_title);
        for (int i = 0; i < title.length; i++) {
            mTb.addTab(mTb.newTab().setText(title[i]));
//            bundle.putString("url",url[i]);
        }
//        FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
//        StarSaleFragment starSaleFragment = new StarSaleFragment();
//        starSaleFragment.setArguments(bundle);
//        transaction.add(R.id.star_rl,new StarSaleFragment());
//        transaction.commit();
/*
* 想法：通过for循环把title的数据添加到tablayout上，这一步成功了
*       然后的想法是在tablayout下面的relativelayout里放入一个Fragment
*       在这个Fragment中，（因为title数组的大小和对应碎片内容的url地址的url数组的大小一样）
*       每次添加title的时候通过setArguments给Fragment传一个url地址，然后每一次替换都可以得到新url的数据，感觉整体的想法应该就是在这里
*       出了问题。是不是逻辑上出错了？
*
* */
    }

}
